<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Order extends Controller_Common {

	public $template='layout/advanced';

	public function action_index() {
		$u = Cookie::get('user', NULL);

		if (!empty($u)) {
			$managers = ORM::factory('managers')->find_all();
			$_managers = array();

			foreach ($managers as $key => $item) {
				$_managers[$item->id] = $item->fio;
			}

			$orderForm = View::factory('pieces/order_auth', array(
				'managers' => $_managers
			));
		} else {
			$managers = ORM::factory('managers')->find_all();
			$_managers = array();

			foreach ($managers as $key => $item) {
				$_managers[$item->id] = $item->fio;
			}

			$orderForm = View::factory('pieces/order_noauth', array(
				'managers' => $_managers
			));
		}

		$this->template->header=View::factory('pieces/header');
		$this->template->content=View::factory('pages/order', array(
			'orderForm' => $orderForm
		));

		$menu = Model::factory('menu')->getMenu();
        $this->template->footer=View::factory('pieces/footer', array(
            'menu' => $menu
        ));
	}

	public function action_order() {
		$this->request->redirect('advanced'); // типа заказали
	}

}